package top.lingkang.finalgateway.admin.mapper;

import org.apache.ibatis.annotations.Select;
import top.lingkang.finalgateway.admin.entity.ConfigHistoryEntity;
import top.lingkang.finalgateway.admin.param.HistorySearchParam;
import top.lingkang.finalgateway.admin.vo.ConfigHistoryVO;
import top.lingkang.mm.annotation.MagicMapper;
import top.lingkang.mm.orm.BaseMapper;

import java.util.List;

/**
 * @author lingkang
 * Created by 2024/4/28
 */
@MagicMapper
public interface ConfigHistoryMapper extends BaseMapper<ConfigHistoryEntity> {

    List<ConfigHistoryVO> list(HistorySearchParam param);

    @Select("select id from t_config_history order by create_time desc limit 1")
    String lastId();

    @Select("select xml from t_config_history order by create_time desc limit 1")
    String lastXML();

    default void add(String xml, String type, String old, String remark) {
        ConfigHistoryEntity entity = new ConfigHistoryEntity();
        entity.setXml(xml);
        entity.setOld(old);
        entity.setType(type);
        entity.setRemark(remark);
        insert(entity);
    }
}
